package com.dp.service.impl3;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dp.pojo.JsonPage;
import com.dp.service.impl3.BaseImpl;
import com.dp.vo.NewsResources;

@Service
@Transactional
public class sysresourcefileServiceImpl extends BaseImpl{
	/**
	 * 得到系统图标记录,分页
	 * @return
	 */
	public List<NewsResources> findSysicons(JsonPage jpage,int firstrow, int maxrow) 
	{
		String hql = "SELECT a FROM NewsResources a where 1=1 and (a.isusebysys=1 or resourcetype=13)";
		if (jpage != null && jpage.getSidx() != null
				&& !"".equals(jpage.getSidx())) {
			hql += " order by a." + jpage.getSidx();
			hql += " " + jpage.getSord();
		}
		return getQueryList(hql, firstrow, maxrow);
	}
	
	/**
	 * 得到系统图标记录数
	 * @return 
	 */
	public Long findSysiconsCount() 
	{
	
		String hql = "SELECT count(a) FROM NewsResources a where 1=1 and (a.isusebysys=1 or resourcetype=13)";
		
		Object obj = getSingleResult(hql);
		if(obj ==null ){
			return Long.valueOf(0+"");
		}else{
			return (Long) obj;
		}
	}
	/**
	 * 得到系统图标记录,分页
	 * @return
	 */
	public List<NewsResources> findSysicons(int firstrow, int maxrow) 
	{
		String hql = "SELECT a FROM NewsResources a where 1=1 and a.isusebysys=1 order by a.rid desc";	
		return getQueryList(hql, firstrow, maxrow);
	}
}
